<?php require_once('../Connections/agriculture.php'); ?>
<?php
mysql_select_db($database_agriculture, $agriculture);
$query_seedingRecordset1 = "SELECT * FROM seeding";
$seedingRecordset1 = mysql_query($query_seedingRecordset1, $agriculture) or die(mysql_error());
$row_seedingRecordset1 = mysql_fetch_assoc($seedingRecordset1);
$totalRows_seedingRecordset1 = mysql_num_rows($seedingRecordset1);

$currentPage = $_SERVER["PHP_SELF"];

$maxRows_seeddingRecordset1 = 10;
$pageNum_seeddingRecordset1 = 0;
if (isset($_GET['pageNum_seeddingRecordset1'])) {
    $pageNum_seeddingRecordset1 = $_GET['pageNum_seeddingRecordset1'];
}
$startRow_seeddingRecordset1 = $pageNum_seeddingRecordset1 * $maxRows_seeddingRecordset1;

mysql_select_db($database_agriculture, $agriculture);
$query_seeddingRecordset1 = "SELECT * FROM seeding ORDER BY seeding_id ASC";
$query_limit_seeddingRecordset1 = sprintf("%s LIMIT %d, %d", $query_seeddingRecordset1, $startRow_seeddingRecordset1, $maxRows_seeddingRecordset1);
$seeddingRecordset1 = mysql_query($query_limit_seeddingRecordset1, $agriculture) or die(mysql_error());
$row_seeddingRecordset1 = mysql_fetch_assoc($seeddingRecordset1);

$checkedItems = $_POST["checkbox"];
if ($checkedItems) {
    foreach ($checkedItems as $item) {
        $deleteSelectSql = "delete from seeding where seeding_id=" . $item;
        $deleteSelectResult = mysql_query($deleteSelectSql, $agriculture) or die(mysql_error());
    }
    if ($deleteSelectResult) {
        echo "成功删除" . count($checkedItems) . "条记录";
        echo '<meta http-equiv="refresh" content="0;url=dryumiao.php">';
    }
}


if ($_GET["action"] == "delete" && $_GET["id"] != "") {
    $deleteSql = "delete from seeding where seeding_id=" . $_GET["id"];
    $deleteResult = mysql_query($deleteSql, $agriculture) or die(mysql_error());
    if ($deleteResult) {
        echo "成功删除1条记录";
        echo '<meta http-equiv="refresh" content="0;url=dryumiao.php">';
    }
}


if (isset($_GET['totalRows_seeddingRecordset1'])) {
    $totalRows_seeddingRecordset1 = $_GET['totalRows_seeddingRecordset1'];
} else {
    $all_seeddingRecordset1 = mysql_query($query_seeddingRecordset1);
    $totalRows_seeddingRecordset1 = mysql_num_rows($all_seeddingRecordset1);
}
$totalPages_seeddingRecordset1 = ceil($totalRows_seeddingRecordset1 / $maxRows_seeddingRecordset1) - 1;

$queryString_seeddingRecordset1 = "";
if (!empty($_SERVER['QUERY_STRING'])) {
    $params = explode("&", $_SERVER['QUERY_STRING']);
    $newParams = array();
    foreach ($params as $param) {
        if (stristr($param, "pageNum_seeddingRecordset1") == false &&
                stristr($param, "totalRows_seeddingRecordset1") == false) {
            array_push($newParams, $param);
        }
    }
    if (count($newParams) != 0) {
        $queryString_seeddingRecordset1 = "&" . htmlentities(implode("&", $newParams));
    }
}
$queryString_seeddingRecordset1 = sprintf("&totalRows_seeddingRecordset1=%d%s", $totalRows_seeddingRecordset1, $queryString_seeddingRecordset1);
?>
<style type="text/css">
<!--
.STYLE4 {font-size: 14px}
-->
</style>
<title>修改/删除育苗信息</title><table border="1" cellpadding="0" cellspacing="0">
    <tr>
        <td width="150" class="STYLE4"><table width="150" height="200" border="1" cellpadding="0" cellspacing="0" class="STYLE4">
                <tr>
                    <td width="123"><div align="center"><a href="syumiao.php">查看信息</a></div></td>
                </tr>
                <tr>
                    <td><div align="center"><a href="wyumiao.php">录入信息</a></div></td>
                </tr>
                <tr>
                    <td><div align="center"><a href="dryumiao.php">修改/删除信息</a></div></td>
                </tr>
                <tr>
                    <td><div align="center"><a href="out.php">退出登陆</a></div></td>
                </tr>
            </table></td>
    <form action="" method="post" name="form1" class="STYLE4" id="form1" onsubmit="return okToDelete()"><td width="4933"><label></label>
            <label>
                <input type="submit" name="Submit" value="删除选择" />
            </label>
            <table width="800" height="40" border="1" align="center" cellpadding="0" cellspacing="0" class="STYLE4">
                <tr>
                    <td>&nbsp;</td>
                    <td><div align="center">ID</div></td>
                    <td width="60"><div align="center">名称</div></td>
                    <td><div align="center">壮苗选择</div></td>
                    <td><div align="center">种子消毒</div></td>
                    <td><div align="center">基质配比</div></td>
                    <td><div align="center">播种时间</div></td>
                    <td><div align="center">播种光照</div></td>
                    <td><div align="center">播种温度</div></td>
                    <td><div align="center">播种水分</div></td>
                    <td><div align="center">发芽时长</div></td>
                    <td><div align="center">发芽光照</div></td>
                    <td><div align="center">发芽日温</div></td>
                    <td><div align="center">发芽夜温</div></td>
                    <td><div align="center">发芽水分</div></td>
                    <td><div align="center">幼苗期时长</div></td>
                    <td><div align="center">幼苗期光照</div></td>
                    <td><div align="center">幼苗期日温</div></td>
                    <td><div align="center">幼苗期夜温</div></td>
                    <td><div align="center">幼苗期水分</div></td>
                    <td width="30"><div align="center">操作</div></td>
                </tr>
                <?php do { ?>
                    <tr>
                        <td>&nbsp;
                            <label>
                                <input type="checkbox" name="checkbox[]" value="<?php echo $row_seeddingRecordset1['seeding_id']; ?>" />
                            </label></td>
                        <td><div align="center"><?php echo $row_seeddingRecordset1['seeding_id']; ?></div></td>
                        <td><div align="center"><?php echo $row_seeddingRecordset1['seeding_crop']; ?></div></td>
                        <td><?php echo $row_seeddingRecordset1['seeding_choice']; ?></td>
                        <td><?php echo $row_seeddingRecordset1['seeding_disinfect']; ?></td>
                        <td><?php echo $row_seeddingRecordset1['seeding_stroma']; ?></td>
                        <td><?php echo $row_seeddingRecordset1['seeding_sow_time']; ?></td>
                        <td><?php echo $row_seeddingRecordset1['seeding_sow_light']; ?></td>
                        <td><?php echo $row_seeddingRecordset1['seeding_sow_temp']; ?></td>
                        <td><?php echo $row_seeddingRecordset1['seeding_sow_water']; ?></td>
                        <td><?php echo $row_seeddingRecordset1['seeding_grow_term']; ?></td>
                        <td><?php echo $row_seeddingRecordset1['seeding_grow_light']; ?></td>
                        <td><?php echo $row_seeddingRecordset1['seeding_grow_dtemp']; ?></td>
                        <td><?php echo $row_seeddingRecordset1['seeding_grow_ntemp']; ?></td>
                        <td><?php echo $row_seeddingRecordset1['seeding_grow_water']; ?></td>
                        <td><?php echo $row_seeddingRecordset1['seeding_young_term']; ?></td>
                        <td><?php echo $row_seeddingRecordset1['seeding_young_light']; ?></td>
                        <td><?php echo $row_seeddingRecordset1['seeding_young_dtemp']; ?></td>
                        <td><?php echo $row_seeddingRecordset1['seeding_young_ntemp']; ?></td>
                        <td><?php echo $row_seeddingRecordset1['seeidng_young_water']; ?></td>
                        <td><a href="ryumiao.php?id=<?php echo $row_seeddingRecordset1['seeding_id']; ?>">修改</a><a href="dryumiao.php?action=delete&amp;id=<?php echo $row_seeddingRecordset1['seeding_id']; ?>" onclick="return okToDelete()">删除</a></td>
                        <!--弹出确认删除对话框-->
                    <script language="javascript">
                        function okToDelete(){
                            if(confirm("确定要删除记录吗?"))
                                return true;
                            else
                                return false;
                        }
                    </script>
                    </tr>
                <?php } while ($row_seeddingRecordset1 = mysql_fetch_assoc($seeddingRecordset1)); ?>
            </table>

            <table width="50%" border="0" align="center" class="STYLE4">
                <tr>
                    <td width="23%" align="center"><?php if ($pageNum_seeddingRecordset1 > 0) { // Show if not first page  ?>
                            <a href="<?php printf("%s?pageNum_seeddingRecordset1=%d%s", $currentPage, 0, $queryString_seeddingRecordset1); ?>">第一页</a>
                        <?php } // Show if not first page ?>
                    </td>
                    <td width="31%" align="center"><?php if ($pageNum_seeddingRecordset1 > 0) { // Show if not first page  ?>
                            <a href="<?php printf("%s?pageNum_seeddingRecordset1=%d%s", $currentPage, max(0, $pageNum_seeddingRecordset1 - 1), $queryString_seeddingRecordset1); ?>">上一页</a>
                        <?php } // Show if not first page ?>
                    </td>
                    <td width="23%" align="center"><?php if ($pageNum_seeddingRecordset1 < $totalPages_seeddingRecordset1) { // Show if not last page  ?>
                            <a href="<?php printf("%s?pageNum_seeddingRecordset1=%d%s", $currentPage, min($totalPages_seeddingRecordset1, $pageNum_seeddingRecordset1 + 1), $queryString_seeddingRecordset1); ?>">下一页</a>
                        <?php } // Show if not last page ?>
                    </td>
                    <td width="23%" align="center"><?php if ($pageNum_seeddingRecordset1 < $totalPages_seeddingRecordset1) { // Show if not last page  ?>
                            <a href="<?php printf("%s?pageNum_seeddingRecordset1=%d%s", $currentPage, $totalPages_seeddingRecordset1, $queryString_seeddingRecordset1); ?>">尾页</a>
                        <?php } // Show if not last page ?>
                    </td>
                </tr>
            </table>
            <p>&nbsp;</p>
    </form>
    <p class="STYLE4">&nbsp;</p>
</tr>
</table>
<p class="STYLE4">&nbsp;</p>
<span class="STYLE4">
    <?php
    mysql_free_result($seeddingRecordset1);
    ?>
</span>
<?php
mysql_free_result($seedingRecordset1);
?>
